﻿<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local ="clr-namespace:Cartoons"
             xmlns:vm="clr-namespace:Cartoons.ViewModels"
    xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="Cartoons.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" x:Name="page" d:DataContext="{d:DesignData /SampleData/MainPageViewModelSampleData.xaml}">
    <UserControl.Resources>
        <local:NotNullVisibilityValueConverter x:Key="notNullVisibilityConverter" />
        <local:BoolVisibilityValueConverter x:Key="boolVisibilityConverter" />

        <vm:RelativeToAbsoluteURIConverter x:Key="raconv"/>

    </UserControl.Resources>
    <i:Interaction.Triggers>
        <i:EventTrigger>
            <ei:GoToStateAction x:Name="gotoGridViewState" TargetObject="{Binding ElementName=page}" StateName="Grid"/>
        </i:EventTrigger>
        <i:EventTrigger>
            <ei:GoToStateAction x:Name="gotoNoBookSelectedState1" TargetObject="{Binding ElementName=page}" StateName="NoBookSelected"/>
        </i:EventTrigger>
        <i:EventTrigger>
            <ei:GoToStateAction TargetObject="{Binding ElementName=page}" StateName="Off"/>
        </i:EventTrigger>
        <i:EventTrigger>
            <ei:GoToStateAction x:Name="gotoNoFilterSelected" TargetObject="{Binding ElementName=page}" StateName="NoFilterSelected"/>
        </i:EventTrigger>
        <ei:DataTrigger Binding="{Binding IsLoading}" Value="True">
        	<ei:GoToStateAction x:Name="gotoLoadingState" TargetObject="{Binding ElementName=page}"/>
        </ei:DataTrigger>
        <ei:DataTrigger Binding="{Binding IsLoading}" Value="False">
        	<ei:GoToStateAction x:Name="gotoLoadedState" TargetObject="{Binding ElementName=page}" StateName="Loaded"/>
        </ei:DataTrigger>
    </i:Interaction.Triggers>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ViewModes">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Grid">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="dataGrid">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="searchResultViewer" d:IsOptimized="True"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="searchResultViewer">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="table">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="List">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="searchResultViewer">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="dataGrid" d:IsOptimized="True"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="list">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="FilterStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.3">
                        <VisualTransition.GeneratedEasingFunction>
                            <CircleEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="FilterSelected">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="filterDetails" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="NoFilterSelected">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="filterDetails" d:IsOptimized="True"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="filterDetails">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="BookSelectionStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.3"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="BookSelected">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="libraryCardRegion" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="NoBookSelected">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="libraryCardRegion">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="BookDetails">
                <VisualState x:Name="On">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="bookDetails" d:IsOptimized="True"/>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="search" d:IsOptimized="True"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="search">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="table">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="list">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="showDetails">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Off">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="bookDetails">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="hideDetails">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="print">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="deepZoomBook" d:IsOptimized="True"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="deepZoomBook">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="IsLoading">
            	<VisualState x:Name="Loading"/>
            	<VisualState x:Name="Loaded">
            		<Storyboard>
            			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loading">
            				<DiscreteObjectKeyFrame KeyTime="0">
            					<DiscreteObjectKeyFrame.Value>
            						<Visibility>Collapsed</Visibility>
            					</DiscreteObjectKeyFrame.Value>
            				</DiscreteObjectKeyFrame>
            			</ObjectAnimationUsingKeyFrames>
            			<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loading" d:IsOptimized="True"/>
            		</Storyboard>
            	</VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid x:Name="search" Grid.RowSpan="2">
            <i:Interaction.Triggers>
                <ei:DataTrigger Binding="{Binding SelectedFilter}" Comparison="NotEqual" Value="{x:Null}">
                    <ei:GoToStateAction x:Name="gotoFilterSelectedState" TargetObject="{Binding ElementName=page}" StateName="FilterSelected"/>
                </ei:DataTrigger>
                <ei:DataTrigger Value="{x:Null}" Binding="{Binding SelectedFilter}" Comparison="Equal">
                    <ei:GoToStateAction x:Name="gotoNoFilterSelectedState" TargetObject="{Binding ElementName=page}" StateName="NoFilterSelected"/>
                </ei:DataTrigger>
                <ei:DataTrigger Binding="{Binding SelectedBook}" Value="{x:Null}">
                    <ei:GoToStateAction x:Name="gotoNoBookSelectedState" StateName="NoBookSelected"/>
                </ei:DataTrigger>
                <ei:DataTrigger Comparison="NotEqual" Binding="{Binding SelectedBook}" Value="{x:Null}">
                    <ei:GoToStateAction x:Name="gotoBookSelectedState" StateName="BookSelected"/>
                </ei:DataTrigger>
            </i:Interaction.Triggers>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="203*" />
                <RowDefinition Height="Auto" MinHeight="70"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" MinWidth="55"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <!--Відфільтровані книжки-->
            <local:SearchResultViewer x:Name="searchResultViewer" SelectedIndex="{Binding SelectedBookTitle, Mode=TwoWay}"  Grid.Column="1" Grid.RowSpan="3" Opacity="0" Grid.ColumnSpan="2" Indexes="{Binding FilteredBooksTitles}" MouseLeftButtonUp="dataGrid_MouseLeftButtonUp"/>

            <sdk:DataGrid MouseLeftButtonUp="dataGrid_MouseLeftButtonUp" ItemsSource="{Binding FilteredBooks}" SelectedItem="{Binding SelectedBook, Mode=TwoWay}" x:Name="dataGrid" Grid.Column="1" Grid.RowSpan="3" Opacity="0" AutoGenerateColumns="False" Grid.ColumnSpan="2">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Binding="{Binding BookName}" Width="2*" Header="Назва" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Binding="{Binding AuthorsBibliographyString}" Width="2*" Header="Автори" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Binding="{Binding PublicationYear}" Width="Auto" Header="Рік видання" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Binding="{Binding PublicationPlace}" Width="*" Header="Місце видання" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Binding="{Binding Publisher}" Width="*" Header="Видавництво" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Binding="{Binding Path=Language.LanguageName}" Width="Auto" Header="Мова" IsReadOnly="True"/>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

            <!--Критерії для фільтрування-->
            <Border x:Name="filters"  Style="{StaticResource BorderWindow}" Grid.RowSpan="2">
                <ListBox ItemsSource="{Binding MainFilters}" x:Name="lbMainFilters"  BorderBrush="{x:Null}" Background="{x:Null}" SelectedItem="{Binding SelectedFilter, Mode=TwoWay}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding DisplayName}" />
                                <Button HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Visibility="{Binding IsApplied, Converter={StaticResource boolVisibilityConverter}}" CommandParameter="{Binding}" Click="Button_Click" Content="x"  Style="{StaticResource ButtonClose}" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Border>

            <Border x:Name="filterDetails"
                Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource BorderWindow}" Opacity="0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Button HorizontalAlignment="Right" VerticalAlignment="Top" Content="x" Command="{Binding CloseFilter}" CommandParameter="{Binding SelectedFilter}" Style="{StaticResource ButtonClose}" />
                    <local:ContentTemplateSelector Content="{Binding SelectedFilter}" Margin="5" MaxWidth="300" Grid.Row="1">
                        <local:ContentTemplateSelector.Resources>
                            <!--Шаблони для різних фільтрів-->
                            <DataTemplate x:Key="text">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <TextBox Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=Explicit}" TextChanged="TextBox_TextChanged" x:Name="tbText" />
                                    <ListBox Grid.Row="1" ItemsSource="{Binding Words}" x:Name="lbWords" MouseLeftButtonUp="lbWords_MouseLeftButtonUp"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding}" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave">
                                                        <ToolTipService.ToolTip>
                                                            <ToolTip>
                                                                <TextBlock Text="{Binding}"/>
                                                            </ToolTip>
                                                        </ToolTipService.ToolTip>
                                                    </TextBlock>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                    </ListBox>
                                </Grid>
                            </DataTemplate>
                            <DataTemplate x:Key="range">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Від"/>
                                        <TextBox Text="{Binding Left, Mode=TwoWay}" Margin="5,0"/>
                                        <TextBlock Text="до"/>
                                        <TextBox Text="{Binding Right, Mode=TwoWay}" Margin="5,0"/>
                                    </StackPanel>
                                    <ListBox ItemsSource="{Binding Ranges}" SelectedItem="{Binding SelectedRange, Mode=TwoWay}" Grid.Row="1">
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Left}"/>
                                                    <TextBlock Text=" - "/>
                                                    <TextBlock Text="{Binding Right}"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                    </ListBox>
                                </Grid>
                            </DataTemplate>
                            <DataTemplate x:Key="category">
                                <ItemsControl ItemsSource="{Binding Options}">
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" />
                                                <TextBlock Text="{Binding Item.Text}" Margin="5,0" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </DataTemplate>
                        </local:ContentTemplateSelector.Resources>
                    </local:ContentTemplateSelector>
                    <Button HorizontalAlignment="Right" Grid.Row="2" VerticalAlignment="Bottom" Content="Застосувати" Command="{Binding ApplyFilters}" CommandParameter="{Binding SelectedFilter}" Style="{StaticResource ButtonMetro}" />
                    
                </Grid>
            </Border>

            <Grid x:Name="libraryCardRegion" Grid.ColumnSpan="3" Grid.RowSpan="3" HorizontalAlignment="Right" VerticalAlignment="Center" Opacity="0" >
                <local:LibraryCard x:Name="libraryCard" DataContext="{Binding SelectedBook}" Height="Auto" />
                <Button x:Name="hideBookDetails" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Content="x"  Style="{StaticResource ButtonClose}" d:LayoutOverrides="Width" HorizontalAlignment="Right" VerticalAlignment="Top">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <i:InvokeCommandAction Command="{Binding UnselectBook}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
                <Button x:Name="showDetails" Content="Переглянути книгу" Style="{StaticResource ButtonMetro}" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <ei:GoToStateAction StateName="On"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </Grid>
        </Grid>
        <Grid x:Name="bookDetails" Grid.RowSpan="2" Opacity="0">
            <local:DeepZoomBook x:Name="deepZoomBook" BookSource="{Binding SelectedBook.DzcFileLocation, Converter={StaticResource raconv}}"/>
        </Grid>
        <StackPanel x:Name="menu" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,0,0,1">
            <Button x:Name="table" Content="Таблиця" Style="{StaticResource ButtonMetro}" >
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:GoToStateAction StateName="Grid"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
            <Button x:Name="list" Content="Список" Style="{StaticResource ButtonMetro}" >
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:GoToStateAction StateName="List"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>

            <Button x:Name="print" Content="Друкувати" Style="{StaticResource ButtonMetro}" Click="print_Click"></Button>
            <Button x:Name="hideDetails" Content="Повернутися" Style="{StaticResource ButtonMetro}" >
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:GoToStateAction StateName="Off"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
            <Button x:Name="about" Content="Про проект" Style="{StaticResource ButtonMetro}" Click="about_Click"/>
        </StackPanel>
        <StackPanel  Grid.Row="2" Background="White" Orientation="Horizontal" HorizontalAlignment="Stretch"  VerticalAlignment="Bottom">
        <StackPanel Orientation="Vertical"  HorizontalAlignment="Left">
            <Image Source="mslogo-1.jpg" Stretch="Uniform" Height="16" HorizontalAlignment="Left"/>
            <TextBlock Text="Сайт розроблений за підтримки корпорації Майкрософт" />
        </StackPanel>
        </StackPanel>
        <controlsToolkit:BusyIndicator x:Name="loading" Grid.RowSpan="3" Opacity="0.78">
            <Grid  Background="White">
                <TextBlock Text="Зачекайте, будь-ласка..." HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Grid>
        </controlsToolkit:BusyIndicator>
    </Grid>
</UserControl>
